package com.dataStructure.图;

import org.junit.jupiter.api.Test;

public class GraphTest {
    /*static 图.WeightManager<Double> weightManager = new 图.WeightManager<Double>() {
        @Override
        public int compare(Double w1, Double w2) {
            return w1.compareTo(w2);
        }

        @Override
        public Double add(Double w1, Double w2) {
            return w1 + w2;
        }
    };

    *//*@Test
    public void test1(){
        图_基于邻接表实现<String,Integer> graph = new 图_基于邻接表实现<>();
        graph.addEdge("V1","V0",9);
        graph.addEdge("V1","V2",3);
        graph.addEdge("V2","V0",2);
        graph.addEdge("V2","V3",5);
        graph.addEdge("V3","V4",1);
        graph.addEdge("V0","V4",6);

        graph.removeVertext("V0");
        graph.print();
    }*//*
*//*
    @Test
    public void test2(){
        图<Object, Double> graph = undirectedGraph(Data.DFS_01);

        graph.bfs_non_recursive(1,v -> {
            System.out.println(v);
            return v.equals(20);
            //return false;
        });
    }*//*

    *//**
     * 有向图
     *//*
    private static 图<Object, Double> directedGraph(Object[][] data) {
        图<Object, Double> graph = new 图_基于邻接表实现<>(weightManager);
        for (Object[] edge : data) {
            if (edge.length == 1) {
                graph.addVertex(edge[0]);
            } else if (edge.length == 2) {
                graph.addEdge(edge[0], edge[1]);
            } else if (edge.length == 3) {
                double weight = Double.parseDouble(edge[2].toString());
                graph.addEdge(edge[0], edge[1], weight);
            }
        }
        return graph;
    }

    *//**
     * 无向图
     * @param data
     * @return
     *//*
    private static 图<Object, Double> undirectedGraph(Object[][] data) {
        图<Object, Double> graph = new 图_基于邻接表实现<>(weightManager);
        for (Object[] edge : data) {
            if (edge.length == 1) {
                graph.addVertex(edge[0]);
            } else if (edge.length == 2) {
                graph.addEdge(edge[0], edge[1]);
                graph.addEdge(edge[1], edge[0]);
            } else if (edge.length == 3) {
                double weight = Double.parseDouble(edge[2].toString());
                graph.addEdge(edge[0], edge[1], weight);
                graph.addEdge(edge[1], edge[0], weight);
            }
        }
        return graph;
    }*/
}
